import { defineStore } from "pinia";
interface Global {
  themeList: string[];
  themeIndex: number;
  isReady: boolean;
}
export const useGlobalStore = defineStore("global", {
  state: () =>
    <Global>{
      themeList: ["", "dark"],
      themeIndex: 0,
      isReady: false,
    },

  getters: {
    theme(state): string {
      return state.themeList[state.themeIndex];
    },
  },

  actions: {
    changeTheme() {
      let index: number = this.themeIndex + 1;
      if (index === this.themeList.length) index = 0;
      this.themeIndex = index;
    },

    ready() {
      this.isReady = true;
    },
  },
});
